<template>
    <div class="school">
        <h2>学校名称: {{ name }}</h2>
        <h2>学校地址: {{ address }}</h2>
        <h2>学生姓名: {{studentName}}</h2>
    </div>
</template>

<script>
    export default {
        name: 'School',
        data(){
            return {
                name: 'school',
                address: 'road',
                studentName: ''
            }
        },
        mounted(){
            this.$bus.$on('hello', (name) =>{
                console.log("School收到了学生名：" + name);
                this.studentName = name;
            })
        },
        beforeDestroy(){
            this.$bus.$off('hello');
        },
    }
</script>

<style scoped>
    .school{
        background-color: lightblue;
        padding: 5px;
    }
</style>